package com.weixing.mall.provider.service;

import com.google.common.collect.Lists;
import com.weixing.mall.core.properties.WeiXingProperties;
import com.weixing.mall.core.support.ImageService;
import com.weixing.mall.core.support.imgsearch.ImgSearchAddDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AsyncService {
    @Autowired
    private WeiXingProperties weiXingProperties;
    // 指定使用beanname为doSomethingExecutor的线程池
    @Async("doSomethingExecutor")
    public String doSomething(String message, List<ImgSearchAddDto> imgSearchAddDtos) {
        System.out.println("do something, message={}"+message);
        try {
                ImageService imageService = new ImageService();
                imageService.add(imgSearchAddDtos, weiXingProperties.getAli().getImg());
        } catch (Exception e) {
            e.printStackTrace();
        }
        return message;
    }
}
